package md.lanjing.com.module_deal_center.contact;

import android.content.Context;


import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.Md5Utils;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;



import com.lxh.baselibray.constant.Constant;

import md.lanjing.com.module_deal_center.api.DealApiService;

import md.lanjing.com.module_deal_center.bean.AddSaleOrderRequest;
import com.lxh.baselibray.base.BaseResponce;
import retrofit2.Call;
import retrofit2.Response;

public class ConsignmentContact {
    public static class ConsignmentPresent extends BasePresent<IConsignmentView> {
        public void addConsignmentOrder(final Context context, int weChat, int aliPay, int bank, String type, double tokenNum, double cnyPrice, String dealPwd){
            DealApiService service= ServiceGenerator.createService(DealApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            AddSaleOrderRequest request=new AddSaleOrderRequest(userId,weChat,aliPay,bank,type,tokenNum,cnyPrice, Md5Utils.stringToMD5(dealPwd));
            service.addSaleOrder(request).enqueue(new NetCallBack<BaseResponce>() {
                @Override
                public void onSuccess(Call<BaseResponce> call, Response<BaseResponce> response) {
                    if (getView()!=null){
                        getView().getAddConsignmentOrderData(response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,"网络请求异常");
                }
            });

        }


    }

    public interface IConsignmentView extends IBaseView {
        void getAddConsignmentOrderData(Response<BaseResponce> response);
    }
}
